package com.zeroup.matrix;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.StringUtils;
import com.zeroup.matrix.bean.UserInfo;

import org.kymjs.kjframe.KJActivity;
import org.kymjs.kjframe.KJDB;
import org.kymjs.kjframe.utils.KJLoger;

import java.util.List;

public abstract class BaseActivity extends KJActivity {

    public  String getToken(){
        KJDB db = KJDB.create(this);
        List<UserInfo> userInfoList = db.findAll(UserInfo.class);
        KJLoger.debug("UserInfo===>", JSON.toJSONString(userInfoList));
        if(!userInfoList.isEmpty()) {
            if (!StringUtils.isEmpty(userInfoList.get(0).getToken())) {
                return userInfoList.get(0).getToken();
            }
        }
        return null;
    }

    public void toLogin(Activity activity){
        Intent mIntent = new Intent(activity, DouYinLoginActivity.class);
        startActivity(mIntent);
        activity.finish();
    }
}